//
//  SelectLearn+net.m
//  星期6
//
//  Created by 宗镇荣 on 16/2/25.
//  Copyright © 2016年 zzr. All rights reserved.
//

#import "SelectLearn+net.h"
#import "NetDefine.h"
#import "AFNetworking.h"
@implementation SelectLearn (net)

+(void)requestWithPageNumber:(NSInteger)page sBlock:(SBlock)block {

    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager GET:kShoppingUrl parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSDictionary *dataDict = dict[@"data"];
        NSArray *itemArray = dataDict[@"items"];
        NSMutableArray *tempArray = [[NSMutableArray alloc] init];
        for (NSDictionary *subDict in itemArray) {
            SelectLearn *model = [[SelectLearn alloc] initWithDictionary:subDict error:nil];
            [tempArray addObject:model];
        }
        block(tempArray, nil);
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
        block(nil,error);
    }];

}

@end
